<template>
	<view class="uiwu uiwu-flex-column uiwu-flex-center">
		<view class="uiwu-form">
			<view class="item uiwu-flex-align">
				<image src="/static/invite.png" mode="widthFix"></image>
				<input v-model="inviteCode" type="text" placeholder="请输入用户邀请码">
			</view>
		</view>
		<view class="uiwu-button uiwu-flex-center" @tap="tapLogin">确定</view>
	</view>
</template>

<script setup lang="ts">
	import { onNavigationBarButtonTap } from '@dcloudio/uni-app';
	import { ref } from "vue";
	import { uiwu } from '@/config/config';
	import { bindMobile } from "../../api/api";
	const inviteCode = ref<string>(null)
	/**
	 * tapLogin 授权登录
	 */
	const tapLogin = async () : Promise<any> => {
		if(!inviteCode.value) return uiwu.toast('请填写邀请码')
		const result = await bindMobile({
			invite_code:inviteCode.value
		})
		if(!result) return
		uiwu.toast('绑定成功')
		uni.switchTab({
			url:'/pages/index/index'
		})
	} 
	onNavigationBarButtonTap(()=>{
		uni.switchTab({
			url:'/pages/index/index'
		})
	})
</script>

<style lang="scss">
	page{
		background-color: #F6F6F6;
	}
	.uiwu{
		padding: 20rpx 0;
	}
	.uiwu-form{
		width: 100%;
		background: #FFFFFF;
		.item{
			width: 100%;
			height: 136rpx;
			padding: 0 24rpx;
			image{
				width: 44rpx;
				margin-right: 20rpx;
			}
			input{
				flex: 1;
				font-size: 28rpx;
			}
			text{
				font-size: 28rpx;
				font-weight: bold;
				color: #EF821E;
			}
			&:nth-child(1){
				border-bottom: 1rpx solid #F1F1F1;
			}
		}
	}
	.uiwu-button{
		width: 670rpx;
		height: 80rpx;
		background: #EF821E;
		border-radius: 40rpx;
		font-size: 32rpx;
		font-weight: bold;
		color: #FFFFFF;
		margin-top: 40rpx;
	}
</style>
